Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error when switching coupon discount type #599

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

victormattosvm
Copy link
Contributor

@victormattosvm victormattosvm commented Jan 26, 2022

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix/devops branch (right side). Don't pull request from your master!
  • Have you ensured/updated that CLI tests to extend coverage to any new logic. Learn how to modify the tests here.

updateCoupon mutation error

I can't change the coupon discount type from "FIXED PRODUCT" to "PERCENT" or vice versa when the amount is higher than 100 and the amount input is set before the discountType in the mutation.

What does this implement/fix? Explain your changes.

My fix sets the coupon discount type before Woocommerce checks if the amount is valid or not.

Steps to reproduce the issue

1- Create a new coupon with discount type 'FIXED_PRODUCT' and set an amount of 200
2- Change the discount type to 'PERCENT', keeping the same amount. IMPORTANT: put the amount input before the discountType in the mutation.
3. An error will be generated, because when validating the amount, the discount type will still be the old one (PERCENT) and 200 is invalid for percentage.

  • WooGraphQL Version: 0.10.7
  • WPGraphQL Version: 1.6.12
  • WordPress Version: 5.8.3
  • WooCommerce Version: 6.1.0

@victormattosvm victormattosvm changed the title [Fix] Error when switching percent to fixed [Fix] Error when switching coupon discount type from percent to fixed Jan 26, 2022
@victormattosvm victormattosvm changed the title [Fix] Error when switching coupon discount type from percent to fixed [Fix] Error when switching coupon discount type from fixed to percent Jan 26, 2022
@victormattosvm victormattosvm changed the title [Fix] Error when switching coupon discount type from fixed to percent [Fix] Error when switching coupon discount type Jan 26, 2022
Copy link
Member

@kidunot89 kidunot89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@victormattosvm Sorry about my late response. Can you add this scenario as an assertion here.

@kidunot89 kidunot89 changed the title [Fix] Error when switching coupon discount type fix: Error when switching coupon discount type Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants